import config from 'config';
import httpFetch from 'share/httpFetch';
import errorMessage from 'share/errorMessage';

export default {

  /*
    得到列表数据
   */
  getList(params) {
    return new Promise((resolve, reject) => {
      httpFetch.get(`${config.baseUrl}/api/companyLevel/selectByInput`, params)
        .then(res => {
          resolve(res);
        })
        .catch(err => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },

  //点击搜索
  onSearch(item) {
    return new Promise((resolve, reject) => {
      httpFetch.get(`${config.baseUrl}/api/companyLevel/selectByInput`, item)
        .then(res => {
          resolve(res);
        })
        .catch(err => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },

  //新建编辑
  newEditRecord(params) {
    return new Promise((resolve, reject) => {
      httpFetch.post(`${config.baseUrl}/api/companyLevel/insertOrUpdate`, params)
        .then(res => {
          resolve(res);
        })
        .catch(err => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },
}
